package cn.xinfei.xdecision.common.utils.enums.enginex.action;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 动作调用方式枚举
 */
@Getter
@AllArgsConstructor
public enum ActionPostTypeEnum {

    SYNC(1, "同步"),

    ASYNC_THREAD(2, "异步-线程"),

    ASYNC_MQ(3, "异步-MQ");

    private final Integer code;

    private final String desc;

    public static String convertEnum() {
        JSONArray jsonArray = new JSONArray();
        for (ActionPostTypeEnum value : ActionPostTypeEnum.values()) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", value.getCode());
            jsonObject.put("desc", value.getDesc());
            jsonArray.add(jsonObject);
        }
        return jsonArray.toJSONString();
    }
}
